import log from '@dfeidao/atom-nodejs/logger/log';
import { IncomingHttpHeaders } from 'http';
import operate from '@dfeidao/atom-nodejs/db/operate';
import { systemid, productid } from '../../atom/config';
import doc_code from '@dfeidao/atom-nodejs/msg/doc-code';
interface Message {
	filter: {
		plan_cla_attr_no: string;
		plan_cla_attr_name: string;
	}
}

interface IWebResult {
	data: unknown;
	cookie?: {
		[name: string]: string;
	} | null;
	content_type?: string;
	headers?: {
		[key: string]: string;
	};
	attachment?: string;
	redirect?: string;
	status_code?: number;
}

export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders): Promise<IWebResult> {
	log('Service begin path:d:\飞道\新建文件夹\kh\src\liuxinyu\zj-000002\s001,action_id:' + action_id);
	const res = await doc_code(action_id, session_id, systemid, 'BM0014389', '', 1);
	const { exec, insert, } = operate(action_id, session_id, systemid);
	// 插入数据
	insert('plan_classify', { plan_cla_attr_no: res.result, plan_cla_attr_name: message.filter.plan_cla_attr_name, productid, });
	const r = await exec();
	log('Service end path:d:\飞道\新建文件夹\kh\src\liuxinyu\zj-000002\s001,action_id:' + action_id);
	return {
		data: r
	};
}
